package com.caigou.modules.rank.repository

import android.text.TextUtils
import com.caigou.comm.base.bean.HttpResult
import com.caigou.modules.rank.bean.*
import com.caigou.modules.rank.network.HttpRankService
import dagger.hilt.android.scopes.ActivityRetainedScoped
import kotlinx.coroutines.flow.Flow
import okhttp3.RequestBody.Companion.toRequestBody
import org.json.JSONObject
import javax.inject.Inject

/**
 * @author #Suyghur.
 * Created on 2021/11/03
 */
@ActivityRetainedScoped
class RankRepository @Inject constructor() {

    fun getFansRank(date: String, userId: String): Flow<HttpResult<FansRankBean>> {
        return if (TextUtils.isEmpty(date)) {
            HttpRankService.service.getFansRank(userId)
        } else {
            HttpRankService.service.getFansRank(date, userId)
        }
    }

    fun getLevelRank(date: String, userId: String): Flow<HttpResult<LevelRankBean>> {
        return if (TextUtils.isEmpty(date)) {
            HttpRankService.service.getLevelRank(userId)
        } else {
            HttpRankService.service.getLevelRank(date, userId)
        }
    }


    fun getCharmRank(date: String, userId: String): Flow<HttpResult<CharmRankBean>> {
        return if (TextUtils.isEmpty(date)) {
            HttpRankService.service.getCharmRank(userId)
        } else {
            HttpRankService.service.getCharmRank(date, userId)
        }
    }

    fun getContributionRank(date: String, userId: String): Flow<HttpResult<ContributionRankBean>> {
        return if (TextUtils.isEmpty(date)) {
            HttpRankService.service.getContributionRank(userId)
        } else {
            HttpRankService.service.getContributionRank(date, userId)
        }
    }

    fun getMasterRank(date: String, userId: String): Flow<HttpResult<MasterRankBean>> {
        return if (TextUtils.isEmpty(date)) {
            HttpRankService.service.getMasterRank(userId)
        } else {
            HttpRankService.service.getMasterRank(date, userId)
        }
    }
}